package Reflect;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
public class Test2 {
    public static void main(String[] args) throws Exception {
        Class cla=Class.forName("Reflect.Person");
        Object obj=cla.newInstance();
        Method[] methods = cla.getMethods();
        for (Method method:methods){
            if (method.getParameterCount()==0
                    &&
                method.getModifiers()==Modifier.PUBLIC
                    &&
                method.getName().contains("s")
            ) {
                System.out.println("调用方法:" + method.getName());
                method.invoke(obj);
            }
        }
    }
}